package pers.sen.health.controller;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import pers.sen.health.dto.CheckGroupDTO;
import pers.sen.health.entity.QueryPageBean;
import pers.sen.health.entity.Result;
import pers.sen.health.po.CheckGroup;
import pers.sen.health.service.CheckGroupService;

/**
 * @author Jason
 * @version 1.0.0
 * @date 2020/11/5 9:57
 * @Description TODO
 */
@RestController
public class CheckGroupController {

    // 获取服务
    @Reference
    private CheckGroupService checkGroupService;

    // 查询所有检查组
    @GetMapping("checkgroup/findAll")
    public Result findAll() {
        return new Result(checkGroupService.list());
    }

    // 分页查询
    @PostMapping("checkgroup/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        return new Result(checkGroupService.findPage(queryPageBean));
    }

    // 添加修改
    @PostMapping("checkgroup/addOrUpdate")
    public Result addOrUpdate(@RequestBody CheckGroupDTO checkGroupDTO) {
        return new Result(checkGroupService.insertCheckGroup(checkGroupDTO));
    }

    // 删除（改变显示状态）
    @PostMapping("checkgroup/updateIsDeleteById")
    public Result updateIsDeleteById(@RequestBody CheckGroup checkGroup) {
        return new Result(checkGroupService.updateIsDeleteById(checkGroup));
    }

    @GetMapping("checkgroup/findCheckItemInfoByGroupId/{id}")
    public Result findCheckItemInfoByGroupId(@PathVariable("id") int id) {
        return new Result(checkGroupService.findCheckItemInfoByGroupId(id));
    }
}
